package org.niu.sort;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.PriorityQueue;

public class FindKth {
    public ArrayList<Integer> GetLeastNumbers_Solution(int [] input, int k) {
        // write code here
        PriorityQueue<Integer> q = new PriorityQueue<>();
        for(int t:input){
            q.add(t);
        }
        ArrayList<Integer> ans = new ArrayList<>();
        for (int i = 0; i < k; i++) {
            Integer head = q.poll();
            ans.add(head);
        }
        return ans;
    }
}
